package com.bsoft.gol.hcs.specialist.service;

import ctd.controller.exception.ControllerException;
import hcn.util.BaseResponse;
import com.bsoft.gol.hcs.specialist.bean.response.ExecuteFactorResponse;
import com.bsoft.gol.hcs.specialist.bean.response.FactorData;
import com.bsoft.gol.hcs.specialist.entity.FollowUpRoute;
import com.bsoft.gol.hcs.specialist.entity.FollowUpRouteDetail;
import com.bsoft.gol.hcs.specialist.entity.FollowUpRouteDetailFactor;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @author tongtp
 * @version v0.1
 * @package specialist.service
 * @className IFollowUpCommonService
 * @description 随访公共服务
 * @create 2022-05-26 9:10
 **/
public interface IFollowUpCommonService {

	/**
	 * 执行诊断因素
	 *
	 * @param followUpRouteDetailFactor 因素记录
	 * @param isLoopExecute             循环执行机制 0 不执行 1 执行
	 * @param followType                随访大类类型 1-专病随访，2-院后随访，3-满意度随访
	 * @param patientIdList             病人id集合，如果传入不为空的话，可以根据传入的参数缩小检索范围
	 * @return org.atag.core.base.BaseResponse<specialist.bean.response.ExecuteFactorResponse>
	 * @throws
	 */
	BaseResponse<ExecuteFactorResponse> executeFactorForDiagnosis(FollowUpRouteDetailFactor followUpRouteDetailFactor,
																  Byte isLoopExecute,
																  String followType,
																  List<String> patientIdList);

	/**
	 * 执行手术因素
	 *
	 * @param followUpRouteDetailFactor 因素记录
	 * @param isLoopExecute             循环执行机制 0 不执行 1 执行
	 * @param followType                随访大类类型 1-专病随访，2-院后随访，3-满意度随访
	 * @param patientIdList             病人id集合，如果传入不为空的话，可以根据传入的参数缩小检索范围
	 * @return org.atag.core.base.BaseResponse<specialist.bean.response.ExecuteFactorResponse>
	 * @throws
	 */
	BaseResponse<ExecuteFactorResponse> executeFactorForOperation(FollowUpRouteDetailFactor followUpRouteDetailFactor,
																  Byte isLoopExecute,
																  String followType,
																  List<String> patientIdList);
	/**
	 * 执行关联指标因素
	 *
	 * @param followUpRouteDetailFactor 因素记录
	 * @param isLoopExecute             循环执行机制 0 不执行 1 执行
	 * @param followType                随访大类类型 1-专病随访，2-院后随访，3-满意度随访
	 * @param patientIdList             病人id集合，如果传入不为空的话，可以根据传入的参数缩小检索范围
	 * @return org.atag.core.base.BaseResponse<specialist.bean.response.ExecuteFactorResponse>
	 * @throws
	 */
	BaseResponse<ExecuteFactorResponse> executeFactorForRelatedIndicators(FollowUpRouteDetailFactor followUpRouteDetailFactor,
																  Byte isLoopExecute,
																  String followType,
																  List<String> patientIdList);
	/**
	 * 执行路径分支因素
	 *
	 * @param followUpRouteDetailFactor 因素记录
	 * @param isLoopExecute             循环执行机制 0 不执行 1 执行
	 * @param followType                随访大类类型 1-专病随访，2-院后随访，3-满意度随访
	 * @param patientIdList             病人id集合，如果传入不为空的话，可以根据传入的参数缩小检索范围
	 * @return org.atag.core.base.BaseResponse<specialist.bean.response.ExecuteFactorResponse>
	 * @throws
	 */
	BaseResponse<ExecuteFactorResponse> executeFactorForPathBranch(FollowUpRouteDetailFactor followUpRouteDetailFactor,
																  Byte isLoopExecute,
																  String followType,
																  List<String> patientIdList);
	/**
	 * 执行接诊医生因素
	 *
	 * @param followUpRouteDetailFactor 因素记录
	 * @param isLoopExecute             循环执行机制 0 不执行 1 执行
	 * @param followType                随访大类类型 1-专病随访，2-院后随访，3-满意度随访
	 * @param patientIdList             病人id集合，如果传入不为空的话，可以根据传入的参数缩小检索范围
	 * @return org.atag.core.base.BaseResponse<specialist.bean.response.ExecuteFactorResponse>
	 * @throws
	 */
	BaseResponse<ExecuteFactorResponse> executeFactorForAttendingDoctor(FollowUpRouteDetailFactor followUpRouteDetailFactor,
																   Byte isLoopExecute,
																   String followType,
																   List<String> patientIdList);
	/**
	 * 执行责任医生因素
	 *
	 * @param followUpRouteDetailFactor 因素记录
	 * @param isLoopExecute             循环执行机制 0 不执行 1 执行
	 * @param followType                随访大类类型 1-专病随访，2-院后随访，3-满意度随访
	 * @param patientIdList             病人id集合，如果传入不为空的话，可以根据传入的参数缩小检索范围
	 * @return org.atag.core.base.BaseResponse<specialist.bean.response.ExecuteFactorResponse>
	 * @throws
	 */
	BaseResponse<ExecuteFactorResponse> executeFactorForResponsibleDoctor(FollowUpRouteDetailFactor followUpRouteDetailFactor,
																		  Byte isLoopExecute,
																		  String followType,
																		  List<String> patientIdList);
	/**
	 * 执行专病分期因素
	 *
	 * @param followUpRouteDetailFactor 因素记录
	 * @param isLoopExecute             循环执行机制 0 不执行 1 执行
	 * @param followType                随访大类类型 1-专病随访，2-院后随访，3-满意度随访
	 * @param patientIdList             病人id集合，如果传入不为空的话，可以根据传入的参数缩小检索范围
	 * @return org.atag.core.base.BaseResponse<specialist.bean.response.ExecuteFactorResponse>
	 * @throws
	 */
	BaseResponse<ExecuteFactorResponse> executeFactorForSpecificDiseaseStage(FollowUpRouteDetailFactor followUpRouteDetailFactor,
																   Byte isLoopExecute,
																   String followType,
																   List<String> patientIdList);
	/**
	 * 执行专病拓展属性因素
	 *
	 * @param followUpRouteDetailFactor 因素记录
	 * @param isLoopExecute             循环执行机制 0 不执行 1 执行
	 * @param followType                随访大类类型 1-专病随访，2-院后随访，3-满意度随访
	 * @param patientIdList             病人id集合，如果传入不为空的话，可以根据传入的参数缩小检索范围
	 * @return org.atag.core.base.BaseResponse<specialist.bean.response.ExecuteFactorResponse>
	 * @throws
	 */
	BaseResponse<ExecuteFactorResponse> executeFactorForSpecificDiseaseDevelopmentAttribute(FollowUpRouteDetailFactor followUpRouteDetailFactor,
																							Byte isLoopExecute,
																							String followType,
																							List<String> patientIdList);

	/**
	 * 处理因素列表得到人员信息集合和因素数据集合
	 *
	 * @param followUpRoute
	 * @param isLoopExecute
	 * @param followUpRouteDetailFactors
	 * @param previousList
	 * @param patientInfoMap
	 * @return void
	 * @throws
	 * @author tongtp
	 * @date 2022/5/30 14:51
	 */
	void handleFactorList(FollowUpRoute followUpRoute, Byte isLoopExecute,
						  List<FollowUpRouteDetailFactor> followUpRouteDetailFactors,
						  List<String> previousList,
						  Map<String, List<FactorData>> patientInfoMap) throws ControllerException;

	/**
	 * 得到开始时间-第一次随访计划的计划执行时间
	 *
	 * @param followUpRouteDetail 子路径
	 * @param factorDataList      因素数据集合
	 * @param followType          随访大类类型 1-专病随访，2-院后随访，3-满意度随访
	 * @param auditTime           入组时间，专病随访必传
	 * @param recordTime          就诊类型记录时间，院后和满意度必传
	 * @return java.util.Date
	 * @throws
	 * @author tongtp
	 * @date 2022/6/1 10:43
	 */
	Date getStartPlanTime(FollowUpRouteDetail followUpRouteDetail,
						  List<FactorData> factorDataList, String followType,
						  Date auditTime, Date recordTime) throws ControllerException;

	/**
	 * 执行门诊（住院）状态因素
	 *
	 * @param followUpRouteDetailFactor 因素记录
	 * @param isLoopExecute             循环执行机制 0 不执行 1 执行
	 * @param followType                随访大类类型 1-专病随访，2-院后随访，3-满意度随访
	 * @param patientIdList             病人id集合，如果传入不为空的话，可以根据传入的参数缩小检索范围
	 * @param patientFactorTimeMap      病人因素时间集合，key是病人id(patientId)，value是同组(and相连的因素即为同组)其他因素的因素时间最晚的那个
	 * @return org.atag.core.base.BaseResponse<specialist.bean.response.ExecuteFactorResponse>
	 * @throws
	 */
	BaseResponse<ExecuteFactorResponse> executeFactorForOutpatientInpatientStatus(FollowUpRouteDetailFactor followUpRouteDetailFactor,
																				  Byte isLoopExecute,
																				  String followType,
																				  List<String> patientIdList,
																				  Map<String, Date> patientFactorTimeMap);


	/**
	 * 执行医嘱名称因素
	 *
	 * @param followUpRouteDetailFactor 因素记录
	 * @param isLoopExecute             循环执行机制 0 不执行 1 执行
	 * @param followType                随访大类类型 1-专病随访，2-院后随访，3-满意度随访
	 * @param patientIdList             病人id集合，如果传入不为空的话，可以根据传入的参数缩小检索范围
	 * @return org.atag.core.base.BaseResponse<specialist.bean.response.ExecuteFactorResponse>
	 * @throws
	 */
	BaseResponse<ExecuteFactorResponse> executeFactorForMedicalAdviceName(FollowUpRouteDetailFactor followUpRouteDetailFactor,
																		  Byte isLoopExecute, String followType,
																		  List<String> patientIdList);

	/**
	 * @param diseaseTypeId
	 * @param followUpRouteDetail
	 * @param routeDetailId
	 * @param advanceNotifyDate
	 * @throws
	 * @description: 计算得到提前通知时间-天数
	 * @return: java.lang.Integer
	 * @author: tongtp
	 * @date: 2020/7/28 17:39
	 */
	Integer getAdvanceNotifyDate(Long diseaseTypeId, FollowUpRouteDetail followUpRouteDetail,
								 Long routeDetailId, Integer advanceNotifyDate);

	/**
	 * @param advanceNotifyDate
	 * @param notifyDate
	 * @throws
	 * @description: 计算提前通知天数
	 * @return: java.lang.Integer
	 * @author: tongtp
	 * @date: 2020/8/11 16:07
	 */
	Integer getAdvanceNotifyDate(Integer advanceNotifyDate, Byte notifyDate);

	/**
	 * 保存因素数据使用记录
	 *
	 * @param followType          随访大类类型 1-专病随访，2-院后随访，3-满意度随访
	 * @param routeDetailId       子路径id
	 * @param factorDataList      因素数据集合
	 * @param teamChronicGroupId  入组记录 id-专病随访必填
	 * @param fusAfterHosRecordId 随访记录id-院后随访和满意度随访必填
	 * @return void
	 * @throws
	 * @author tongtp
	 * @date 2022/6/7 10:00
	 */
	void saveFusFactorDataRecord(String followType, Long routeDetailId, List<FactorData> factorDataList,
								 Long teamChronicGroupId, String fusAfterHosRecordId);

	/**
	 * 通过机构代码和科室代码查询科室
	 *
	 * @param organizationId
	 * @param departmentId
	 * @return String
	 */
	String getDeptIdByLocalDeptId(String organizationId, String departmentId);

	/**
	 * 通过机构代码查询租户id
	 *
	 * @param organizationId
	 * @return String
	 */
	String getTenantIdByOrgCode(String organizationId);
}
